package com.mine.androidlearn.tempmvp;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.mine.androidlearn.R;
import com.mine.androidlearn.common.base.BaseMvpActivity;
import com.mine.androidlearn.tempdb.DBActivity;
import com.mine.androidlearn.tempnet.NetActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends BaseMvpActivity<IMainContract.view, MainPresenter> implements IMainContract.view {

    @BindView(R.id.btnTest)
    Button btnTest;
    @BindView(R.id.btnTestDB)
    Button btnTestDB;


    @Override
    protected MainPresenter createPresenter() {
        return new MainPresenter(this);
    }

    @Override
    protected void initVariables() {

    }

    @Override
    protected void initViews(Bundle savedInstanceState) {
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
    }

    @Override
    protected void loadData() {

    }

    @OnClick({R.id.btnTest,R.id.btnTestDB})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btnTest:
                mPresenter.login("张三","登录了");
                break;
                case R.id.btnTestDB:
                    startActivity(new Intent(MainActivity.this, DBActivity.class));
                break;
        }

    }

    @Override
    public void loginSuccess() {
        Toast.makeText(MainActivity.this,"张三登陆了",Toast.LENGTH_SHORT).show();
        startActivity(new Intent(MainActivity.this, NetActivity.class));
    }

    @Override
    public void showServerOrNetworkError() {

    }

    @Override
    public void showNetworkNotConnected() {

    }

    @Override
    public void showApiError(String error) {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }
}
